﻿using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.IO;

namespace SortArrayAndFindANumberTest
{
    [TestClass()]
    public class ProgramTest
    {
        [TestMethod()]
        [DeploymentItem("SortArrayAndFindANumber.exe")]
        public void FindNumberOrLessTest()
        {
            int[] numbers = { 2, 5, 6, 8 }; 
            int numberK = 7; 
            Nullable<int> expected = new Nullable<int>();
            expected = 6;
            Nullable<int> actual;
            actual = Program_Accessor.FindNumberOrLess(numbers, numberK);
            Assert.AreEqual(expected, actual);
        }

        [TestMethod()]
        [DeploymentItem("SortArrayAndFindANumber.exe")]
        public void PrintNumbersTest()
        {
            StringWriter consoleOut = new StringWriter();
            Console.SetOut(consoleOut);
            int[] numbers = { 1, 3 };
            Program_Accessor.PrintNumbers(numbers);
            Assert.AreEqual("{ 1 3 }\r\n", consoleOut.ToString());
        }
    }
}
